<template>
	<view>
		<div style='height: 100rpx;'></div>
		<div class='myTabBar'>
			<!-- <div @click='to(1)' v-show='isSelected!=1'>
				<div class='indexImg'></div>
				<div>首页2</div>
			</div>
			<div v-show='isSelected==1'>
				<div class='indexImg'></div>
				<div>首页1</div>
			</div>
			<div @click='to(2)' v-show='isSelected!=2'>
				<div class='indexImg'></div>
				<div>电子书2</div>
			</div>
			<div v-show='isSelected==2'>
				<div class='indexImg'></div>
				<div>电子书1</div>
			</div>
			<div @click='to(3)' v-show='isSelected!=3'>
				<div class='indexImg'></div>
				<div>视频2</div>
			</div>
			<div v-show='isSelected==3'>
				<div class='indexImg'></div>
				<div>视频1</div>
			</div>
			<div @click='to(4)' v-show='isSelected!=4'>
				<div class='indexImg'></div>
				<div>我的2</div>
			</div>
			<div v-show='isSelected==4'>
				<div class='indexImg'></div>
				<div>我的1</div>
			</div> -->
			<div @click='to(1)'>
				<div class='indexImg'></div>
				<div>首页2</div>
			</div>
			<div @click='to(2)'>
				<div class='indexImg'></div>
				<div>电子书2</div>
			</div>
			<div @click='to(3)'>
				<div class='indexImg'></div>
				<div>视频2</div>
			</div>
			<div @click='to(4)'>
				<div class='indexImg'></div>
				<div>我的2</div>
			</div>
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isSelected: 2
			};
		},
		onShow() {
			//console.log('getCurrentPages()==',getCurrentPages())
		},
		mounted(){
			//console.log('执行了mounted')
		},
		methods: {
			to(num) {
				let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
				        let curRoute = routes[routes.length - 1].route //获取当前页面路由
					//console.log('num==', num,curRoute)
					this.isSelected = num
					if (num == 1) {
						uni.navigateTo({
							url: "/pages/index/index"
						})
					} else if (num == 2) {
						uni.navigateTo({
							url: "/pages/book/index"
						})
					} else if (num == 3) {
						uni.navigateTo({
							url: "/pages/video/index"
						})
					} else if (num == 4) {
						uni.navigateTo({
							url: "/pages/my/index"
						})
					}

				// "tabBar": {
				// 	"color": "#C0C4CC", //未选中的菜单文字颜色
				// 	"selectedColor": "#2b78fd", //选中时的菜单文字颜色
				// 	"borderStyle": "black",
				// 	"backgroundColor": "#ffffff", //背景
				// 	"list": [{
				// 			"pagePath": "pages/index1/index", //页面地址
				// 			"iconPath": "static/imgs/icon_tabbar_shujia.png", //未选中时的图片
				// 			"selectedIconPath": "static/imgs/icon_tabbar_shujia_o.png", //选中时的图片
				// 			"text": "首页" //菜单文字
				// 		},
				// 		{
				// 			"pagePath": "pages/book/index",
				// 			"iconPath": "static/imgs/icon_tabbar_dianzishu_o.png", //未选中时的图片
				// 			"selectedIconPath": "static/imgs/icon_tabbar_dianzishu.png", //选中时的图片
				// 			"text": "电子书"
				// 		}, 
				// 		{
				// 			"pagePath": "pages/video/index",
				// 			"iconPath": "static/imgs/icon_tabbar_shipin.png", //未选中时的图片
				// 			"selectedIconPath": "./static/imgs/icon_tabar_shipin_o.png", //选中时的图片
				// 			"text": "视频"
				// 		}, {
				// 			"pagePath": "pages/my/index",
				// 			"iconPath": "static/imgs/icon_tabbar_user.png", //未选中时的图片
				// 			"selectedIconPath": "static/imgs/icon_tabbar_user_o.png", //选中时的图片
				// 			"text": "我的"
				// 		}
				// 	]
				// },
			}
		}
	}
</script>

<style lang="less" scoped>
	.myTabBar {
		display: flex;
		justify-content: space-around;
		align-items: center;
		height: 100rpx;
		position: fixed;
		bottom: 0;
		z-index: 9999;
		width: 100vw;
		background-color: white;
		border-top: 1px solid red;
	}
</style>
